<template>
  <div>
    考勤系统
  </div>
</template>


<script>
import objD from '../../assets/jjson/v1.json'
import carD from '../../assets/jjson/car.json'
import { compareTime, deduplicate, change, goodsidsRecombineToNewJson, carLateAndEarlyDeparture } from '../../utils/attendance'

export default {
  name: "",
  data () {
    return {
      v1: objD,
      carData: carD
    }
  },
  mounted () {
    const _this = this
    // 人员进场
    // _this.divisionIn(_this.v1)

    // 人员出场
    _this.divisionOut(_this.v1)

    // 车辆
    // _this.checkWorkAttendance(_this.carData)

  },
  methods: {
    //进
    divisionIn (inData) {
      const newStr = inData.filter(item => {
        if (item.entryAndExit == '进场') {
          return true
        } else {
          return false
        }
      })
      console.log('newStr:', newStr);
      const lat = newStr.filter(item => {
        if (item.time && compareTime(new Date('2024.04.01 08:35:00'), new Date(item.time)) == 1) {
          return true
        } else {
          return false
        }
      })
      console.log('lat:', lat);
      // change(lat)
    },


    //出场
    divisionOut (outData) {
      const newStr = outData.filter(item => {
        if (item.entryAndExit == '出场') {
          return true
        } else {
          return false
        }
      })
      console.log("newStr:", newStr);
      const early = newStr.filter(item => {
        if (item.time && compareTime(new Date('2024.04.01 17:00:00'), new Date(item.time)) == -1) {
          return true
        } else {
          return false
        }
      })
      // console.log('early:', early);
      // change(early)
    },


    //判断车辆进场出场是否迟到早退
    checkWorkAttendance (carData) {
      // console.log(carData);
      var chineseRegex = /[^\u4e00-\u9fa5]/g; //字符串保留中文 
      let len = carData.length
      for (let i = 0; i < len; i++) {
        if (carData[i].department) {
          carData[i].department = carData[i].department.replace(chineseRegex, '')
        }
        carData[i].lateOrLeaveEarly = carLateAndEarlyDeparture(carData[i].InTime, carData[i].outTime)
      }
      // console.log(carData);
      const newStr = carData.filter(item => {
        if (item.lateOrLeaveEarly !== '') {
          return true
        } else {
          return false
        }
      })
      console.log("newStr:", newStr);
      // change(newStr)

    }
  }
}
</script>

<style scoped></style>